package cn.itcast.bos.before.quarz;

import org.quartz.Job;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Service;

@Service("jobFactory")
public class JobFactory extends AdaptableJobFactory{
	
	@Autowired
	private AutowireCapableBeanFactory autowireCapableBeanFactory;
	@Override
	public Job newJob(TriggerFiredBundle bundle, Scheduler scheduler)
			throws SchedulerException {
		// TODO Auto-generated method stub
		Job newJob = super.newJob(bundle, scheduler);
		 autowireCapableBeanFactory.autowireBean(newJob);
		return newJob;
	}
}
